<?php
//This view is the home-page for the 'logged_in_user'


echo heading("Update your status, mate:", 4);

?>
<div align='middle'>
<?php
//Form to type in an update, that will be showed on the 'wall' down under.
echo form_open('updates/index');
$input = array('name' => 'status', 'id' => 'status', 'size'=> 50);
echo form_input($input);
echo form_submit('update','update');
echo form_close();
echo br();
?>
</div>
<?php
$format = "%d/%m/%Y %h:%i %a";


//Friend_requests should be showed here, if the 'logged_in_user' have any.
echo br(2);
$TABLE = array();
if (count($friend_requests))
{
   echo '<hr size=3 width="90%">';
   
   echo heading("You have Friend Requests!", 5);

        foreach ($friend_requests as $key => $list)
        {
	   $ID = $list->sender;
           $U = $usernames[$ID];

            $string = anchor("users/home/".$ID,$U);
            $string .= br();

            $properties = array(
                                    'src' => 'users/get_photo/'. $ID,
                                    'width' => '120',
                                    'height' => '115'
            );
            $string .= img($properties,true);

            $properties = array();
            $string .= br();

            $string .= anchor("users/accept_friend_request/".$ID, "<small>accept friend request</small>");
            $string .= br();

            $string .= anchor("users/deny_friend_request/".$ID, "<small>deny friend request</small>");
            $string .= br();


            $TABLE[] = $string;
                   	
		
	}
        $tmpl = array (
        'table_open'  => "<table class='grid'>",
        'row_start'   => "<tr valign='top'>",
        );
        $this->table->set_template($tmpl);
        $this->table->set_empty("&nbsp;");
        $pretty = $this->table->make_columns($TABLE,4);

        echo $this->table->generate($pretty);


   echo br();
   echo '<hr size=3 width="90%">';
   echo br(2);
}

//Shows updates from users which 'logged_in_user' follow, as well as 'logged_in_user'
// own updates.
if (count($updates))
{
    foreach ($updates as $key => $list)
        {
            $ID = $list->user_id;
            $U = $usernames[$ID];
            echo "<p>";
            $properties = array(
                    'src' => 'users/get_photo/'. $ID,
                    'width' => '50',
                    'height' => '50',
                    'align' => 'left',
                    'hspace' => '7'
            );
            echo img($properties,true);

            $properties = array();
            $stamp = mysql_to_unix($list->created);

            echo "<b>".$U . ":</b><i> " . "&#8221;" .
                                    $list->update . "&#8221;</i>" .
                                    br() . "<small>".mdate($format,$stamp);

            if ($ID != $user['id'])
            {
                echo nbs() . anchor('users/unfollow/'. $ID, 'unfollow');
            }

            echo "</small></p>";

//          comments($comments,$list->id,'updates',$usernames,$format); //Bilde, tilføj 'comments'

    }

}
?>